package org.example.bookingsystem.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.example.bookingsystem.model.Order;
import org.example.bookingsystem.model.Ticket;

import java.util.Date;
import java.util.List;

@Mapper
public interface SystemMapper {
    @Select("select * from ticketList where status =0 and poll>0 ")
    public List<Ticket> selectAllTickets();
    @Select("select cost from ticketList where tid = #{tid}")
    public int selectTicketCost(int tid);
    @Insert("insert into orderList (uid, tid, cost, create_time, pay_type) " +
            "VALUES (#{uid}, #{tid}, #{cost}, #{createTime}, #{payType})")
    public int addOrder(int uid, int tid, int cost, Date createTime, int payType);
    @Select("select * from orderList where uid = #{uid}")
    public List<Order> selectOrder(int uid);
    @Update("update ticketList set poll = poll-1 where tid = #{tid}")
    public int updatepoll(int tid);
}
